<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php
$user 	=& JFactory::getUser();

//Ordering allowed ?
$ordering = ($this->lists['order'] == 'a.ordering');
$locale = $this->locale[0];
//var_dump($locale);
JHTML::_('behavior.tooltip');
$editor =& JFactory::getEditor();
?>

<script type="text/javascript">
	
	var IE = document.all?true:false;
	if (!IE) document.captureEvents(Event.MOUSEMOVE)
	document.onmousemove = getMouseXY;
	var map_div = document.getElementById('map_div');
	
	var tempX = 0;
	var tempY = 0;
	function getMouseXY(e) {
		if (IE) { // grab the x-y pos.s if browser is IE
			tempX = event.clientX + document.body.scrollLeft;
			tempY = event.clientY + document.body.scrollTop;
		}
		else {  // grab the x-y pos.s if browser is NS
			tempX = e.pageX;
			tempY = e.pageY;
		}  
		if (tempX < 0){tempX = 0;}
		if (tempY < 0){tempY = 0;}  
		//document.adminForm.MouseX.value = tempX;
		//document.adminForm.MouseY.value = tempY;
		
		var map_div = document.getElementById('map_div');
		var tX = tempX - map_div.offsetLeft;
		var tY = tempY - map_div.offsetTop;
		var map_infoX = document.getElementById('map_infoX');
		var map_infoY = document.getElementById('map_infoY');
		//map_infoX.innerHTML = tX;
		//map_infoY.innerHTML = tY;
		document.adminForm.MouseX.value = tX;
		document.adminForm.MouseY.value = tY;
		//map_info.innerHTML = tX + '::' + tY;
	}
	
	//function mapCoordPost(){
	window.addEvent('domready', function(){
	///////////////////////
	
	
		$('map_div').addEvent('click', function(e) {
			e = new Event(e).stop();
		 
			var coord_str = "x=" + document.adminForm.MouseX.value + "&y=" + document.adminForm.MouseY.value ;
			var map_selection = "image=" + document.adminForm.map_id.value ;
			//var url = "/rc3/components/com_bookstore/map_point_plot.php?" + coord_str + "&" + map_selection;
		 	var url = "/joomla_development/indie-bookstore/trunk/scripts/ajax/map_point_plot.php?" + coord_str + "&" + map_selection;
			/**
			 * The simple way for an Ajax request, use onRequest/onComplete/onFailure
			 * to do add your own Ajax depended code.
			 */
			var img = $('map_img');
		//	var new_src = '';
			
			new Ajax(url, {
				method: 'get',
			//	update: new_src
				onComplete: function() {
				//alert(this.response);
				// when complete, we remove the spinner
				//$('mailImage').setProperty('src', site+'mail_image.php?c='+count);
					img.setAttribute('src', url ); 
				}
			}).request();
			//img.
			document.adminForm.x.value = document.adminForm.MouseX.value;
			document.adminForm.y.value = document.adminForm.MouseY.value;
		});
		
		$('map_id').addEvent('onchange', function(e) {
			//alert('change');
			e = new Event(e).stop();
		 
			//var coord_str = "x=" + document.adminForm.MouseX.value + "&y=" + document.adminForm.MouseY.value ;
			
		});
		
		function changeMap(event){
			var coord_str = "x=" + document.adminForm.x.value + "&y=" + document.adminForm.y.value ;
			var map_selection = "image=" + document.adminForm.map_id.value ;
			//var url = "/rc3/components/com_bookstore/map_point_plot.php?" + coord_str + "&" + map_selection;
		 	var url = "/joomla_development/indie-bookstore/trunk/scripts/ajax/map_point_plot.php?" + coord_str + "&" + map_selection;
			/**
			 * The simple way for an Ajax request, use onRequest/onComplete/onFailure
			 * to do add your own Ajax depended code.
			 */
			var img = $('map_img');
			
			new Ajax(url, {
				method: 'get',
				onComplete: function() {
					img.setAttribute('src', url ); 
				}
			}).request();
			
			
		};//end changMap function
		
		var ms = document.getElementById('map_id');
		ms.onchange = changeMap.bindAsEventListener(ms);
		
	}); //end window event
	
	
</script>

<form action="<?php echo $this->request_url; ?>" method="post" name="adminForm" >

<div class="col width-35">
  <div id="map_div" style=" width: 350px; height: 600px;background-color:#CCCCCC" ><img id="map_img" src="<?php
  if(!empty($locale->x)){
  	$setup_url = "/joomla_development/indie-bookstore/trunk/scripts/ajax/map_point_plot.php?image=".$locale->map_id."&x=".$locale->x."&y=".$locale->y;
  }else{
  	//echo '/rc3/components/com_bookstore/map_point_plot.php'
  	$setup_url = "/joomla_development/indie-bookstore/trunk/scripts/ajax/map_point_plot.php?";
  }
  echo $setup_url;
  ?>" /></div>
</div>

<div class="col width-65" style="width:64%">
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'Details' ); ?></legend>

		<table class="admintable" width="200">
		
		<tr>
		<td width="80" align="right" class="key">
				<label for="id">
					<?php echo JText::_( 'Dept/Cat #' ); ?>:
				</label>
			</td>
			<td>
				<input class="text_area" type="text" name="id" id="id" size="17" maxlength="250" value="<?php echo $locale->id; ?>" />
			</td>
		</tr>
		<tr>
		<td width="80" align="right" class="key">
				<label for="dept_cat_desc">
					<?php echo JText::_( 'Dept/Cat Desc' ); ?>:
				</label>
			</td>
			<td>
				<input class="text_area" type="text" name="dept_cat_desc" id="dept_cat_desc" size="17" maxlength="250" value="<?php echo $locale->dept_cat_desc; ?>" />
			</td>
		</tr>
		<tr>
			<td width="80" align="right" class="key">
				<label for="alias">
					<?php echo JText::_( 'Alias' ); ?>:
				</label>
			</td>
			<td>
				<input class="text_area" type="text" name="alias" id="alias" size="17" maxlength="250" value="<?php echo $locale->alias; ?>" />
			</td>
		</tr>
		<tr>
			<td width="80" align="right" class="key">
				<label for="map_selection">
					Map					
				</label>
			</td>
			<td>
			<?php
				//JHTML::genericlist(array $arr, string $name, [string $attribs = null], [string $key = 'value'], [string $text = 'text'], [mixed $selected = NULL], [ $idtag = false], [ $translate = false])
				//var_dump($this->maps);
				//genericlist ( $arr, $tag_name, $tag_attribs, $key, $text, $selected, $idtag, $translate )
				$map_select = JHTMLSelect::genericlist($this->maps, map_id, array('id'=>'map_id'), 'id','title',$locale->map_id);
				echo $map_select;
				/*
				<select class="" type="select" name="map_selection" id="map_selection" value="<?php echo $item->image; ?>" >
					<option value="map1st">1st Floor</option>
					<option value="map2nd">2nd Floor</option>
				</select>
				*/
			?>
			</td>
		</tr>
		<tr>
			<td width="80" align="right" class="key">
				<label for="x">
					X <input type="text" name="MouseX" value="0" size="4" />
					<?php echo JText::_( 'X' ); ?>:
				</label>
			</td>
			<td>
				<input class="text_area" type="text" name="x" id="x" size="5" maxlength="250" value="<?php echo $locale->x; ?>" />
			</td>
		</tr>
		<tr>
			<td width="80" align="right" class="key">
				<label for="y">
					Y <input type="text" name="MouseY" value="0" size="4" />  
					<?php echo JText::_( 'Y' ); ?>:
				</label>
			</td>
			<td>
				<input class="text_area" type="text" name="y" id="y" size="5" maxlength="250" value="<?php echo $locale->y; ?>" />
			</td>
		</tr>
		<?php
		/*
		<tr>
			<td valign="top" align="right" class="key">
				<label for="catid">
					<?php echo JText::_( 'Category' ); ?>:
				</label>
			</td>
			<td>
				<?php echo 'here'; ?>
			</td>
		</tr>
		*/
		?>
	</table>
	</fieldset>
</div>
<div class="col width-65 ">
    <fieldset class="adminform">
				<legend><?php echo JText::_( 'Description' ); ?></legend>

				<table class="admintable" width="100%">
					<tr>
						<td valign="top" colspan="5">
							<?php
							// parameters : areaname, content, width, height, cols, rows, show xtd buttons
							echo $editor->display( 'description',  $locale->description, '100%', '150', '75', '20', false) ;
							?>
						</td>
					</tr>
					</table>
			</fieldset>
<?php
		/*
	<fieldset class="adminform">
				<legend><?php echo JText::_( 'Description' ); ?></legend>

				<table class="admintable" width="100%">
					<tr>
						<td valign="top" colspan="5">
							<?php echo 'here'; ?>
						</td>
					</tr>
					</table>
			</fieldset>
		*/
?>
</div>
<input type="hidden" name="controller" value="locator" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="" />
</form>



